#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define rep(i,a,b) for(register int i = (a);i <= (b);++i)
#define per(i,a,b) for(register int i = (a);i >= (b);--i)  
typedef long long ll;
typedef unsigned long long ull;
using std::string;using std::cin;using std::cout;

char str[1000010],m[1000010];
int len_str,len_m;
int kmp[1000010];

int main(){
    std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("in.in", "r", stdin);
    cin >> m+1 >> str+1;
    len_m = strlen(m+1) , len_str = strlen(str+1);
    int now = 0;
    rep(i,2,len_str){
        while(now && i <= len_str && str[now+1] != str[i]) now = kmp[now];
        if(str[now+1] == str[i]) kmp[i] = ++now;
    }
    now = 0;
    rep(i,1,len_m){
        while(now && i <= len_m && str[now+1] != m[i]) now = kmp[now];
        if(str[now+1] == m[i]) ++now;
        if(now == len_str){
            cout << i - now + 1 << '\n';
        }
    }
    rep(i,1,len_str) cout << kmp[i] << " ";
    return 0;
}